<?php

namespace app\common\model;

//use think\Model;

class WinthdrawalModel extends BaseModel{

	protected $table = 'tp_winthdrawal_record';

	/*
	添加记录
	 */
	public function addData($uid,$cid,$amount,$fee,$rmb,$name,$bank){
		$data = [
			'uid'=>$uid,
			'cid'=>$cid,
			'amount'=>$amount,
			'fee'=>$fee,
			't_amount'=>$amount+$fee,
			'rmb' => $rmb,
			'total_rmb'=>$amount*$rmb,
			'name'=>$name,
			'bank_no'=>$bank,
			'status'=>0,
			'remark'=>'待审核',
			'date'=>$this->getTime(),
		];
		$res = $this->insert($data);
		return $res;
	}

	/*
	获取记录
	 */
	public function getRecord($uid){
		$data = $this->alias('r')
						->join('tp_coin c','c.id=r.cid','LEFT')
						->where('r.uid',$uid)
						->order('r.id desc')
						->field('r.*,c.name coin_name')
						->select();
		return $data;
	}

	/*
	待审核订单
	 */
	public function underCheck($uid){
		$data = $this->where('uid',$uid)->where('status',0)->find();
		if($data){
			return true;
		} else {
			return false;
		}
	}
}